// 通过这个方法,递归,生成用户的路由

//jsDOC

/**
 * 
 * @param {Array} menuList 后台返回的用户菜单
 * @param {Array} routes 用户本地所有的需要校验的动态路由
 * @return {Array} 计算好的动态用户菜单
 */

 const recursionRoutes = (menuList, routes) => {
    // console.log('menulist', menuList)
    // console.log('routes---', routes)
    let userMenu = [];//存储计算的结果
    menuList.forEach(menu => {
        routes.forEach(route => {
            if (menu.title === route.meta.title) {
                //递归
                if (menu.children && menu.children.length) {
                    route.children = recursionRoutes(menu.children, route.children)
                }
                userMenu.push(route)
            }
        })
    })
    return userMenu
}

export default recursionRoutes